package com.morgan.maxfinance;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class CompleteHelp {

	CompleteActivity parent;
	public View view;
	
	LinearLayout 	llytWhatShouldIDoNow;
	LinearLayout 	pageWhatShouldIDoNow;
	ImageView		imagWhatShouldIDoNow;
	
	LinearLayout 	llytWhenWillIGetMoney;
	LinearLayout 	pageWhenWillIGetMoney;
	ImageView		imagWhenWillIGetMoney;
	
	LinearLayout 	llytAmIApproved;
	LinearLayout 	pageAmIApproved;
	ImageView		imagAmIApproved;
	
	LinearLayout 	llytWhatIsTheInterestRate;
	LinearLayout 	pageWhatIsTheInterestRate;
	ImageView		imagWhatIsTheInterestRate;
	
	LinearLayout 	llytWhatIsTheLoanTerm;
	LinearLayout 	pageWhatIsTheLoanTerm;
	ImageView		imagWhatIsTheLoanTerm;
	
	LinearLayout 	llytHowDoIMakeChanges;
	LinearLayout 	pageHowDoIMakeChanges;
	ImageView		imagHowDoIMakeChanges;
	
	LinearLayout 	llytHaveAQuestion;
	LinearLayout 	pageHaveAQuestion;
	ImageView		imagHaveAQuestion;
	
	public CompleteHelp(Context context) {
		// TODO Auto-generated constructor stub
		parent = (CompleteActivity) context;
		
		initWidget();
		initValue();
		initEvent();
	}
	
	private void initWidget() {
    	LayoutInflater inflater = parent.getLayoutInflater();
    	view = inflater.inflate(R.layout.answer_complete, null);
    	
    	llytWhatShouldIDoNow = (LinearLayout) view.findViewById(R.id.what_should_i_do_now_menu);
    	pageWhatShouldIDoNow = (LinearLayout) view.findViewById(R.id.what_should_i_do_now_page);
    	imagWhatShouldIDoNow = (ImageView) view.findViewById(R.id.what_should_i_do_now_imageView);
    	
    	llytWhenWillIGetMoney = (LinearLayout) view.findViewById(R.id.when_will_get_the_money_menu);
    	pageWhenWillIGetMoney = (LinearLayout) view.findViewById(R.id.when_will_get_the_money_page);
    	imagWhenWillIGetMoney = (ImageView) view.findViewById(R.id.when_will_get_the_money_imageView);
    	
    	llytAmIApproved = (LinearLayout) view.findViewById(R.id.am_i_approved_menu);
    	pageAmIApproved = (LinearLayout) view.findViewById(R.id.am_i_approved_page);
    	imagAmIApproved = (ImageView) view.findViewById(R.id.am_i_approved_imageView);
    	
    	llytWhatIsTheInterestRate = (LinearLayout) view.findViewById(R.id.what_is_the_interest_rate_complete_menu);
    	pageWhatIsTheInterestRate = (LinearLayout) view.findViewById(R.id.what_is_the_interest_rate_complete_page);
    	imagWhatIsTheInterestRate = (ImageView) view.findViewById(R.id.what_is_the_interest_rate_complete_imageView);
    	
    	llytWhatIsTheLoanTerm = (LinearLayout) view.findViewById(R.id.what_is_the_loan_term_menu);
    	pageWhatIsTheLoanTerm = (LinearLayout) view.findViewById(R.id.what_is_the_loan_term_page);
    	imagWhatIsTheLoanTerm = (ImageView) view.findViewById(R.id.what_is_the_loan_term_imageView);
    	
    	llytHowDoIMakeChanges = (LinearLayout) view.findViewById(R.id.how_do_i_make_changes_menu);
    	pageHowDoIMakeChanges = (LinearLayout) view.findViewById(R.id.how_do_i_make_changes_page);
    	imagHowDoIMakeChanges = (ImageView) view.findViewById(R.id.how_do_i_make_changes_imageView);
    	
    	llytHaveAQuestion = (LinearLayout) view.findViewById(R.id.have_a_question_menu);
    	pageHaveAQuestion = (LinearLayout) view.findViewById(R.id.have_a_question_page);
    	imagHaveAQuestion = (ImageView) view.findViewById(R.id.have_a_question_imageView);
	}
	
	private void initValue() {
    	allPageGone();
	}
	
	private void initEvent() {
		llytWhatShouldIDoNow.setOnClickListener(new Button.OnClickListener() {    		
			@Override
			public void onClick(View v) {
				if (pageWhatShouldIDoNow.getVisibility() == View.VISIBLE) {
					pageWhatShouldIDoNow.setVisibility(View.GONE);
					imagWhatShouldIDoNow.setImageResource(R.drawable.plus_icon);
				} else {
					allPageGone();
					pageWhatShouldIDoNow.setVisibility(View.VISIBLE);
					imagWhatShouldIDoNow.setImageResource(R.drawable.minus_icon);
				}
			}
        });
		
		llytWhenWillIGetMoney.setOnClickListener(new Button.OnClickListener() {    		
			@Override
			public void onClick(View v) {
				if (pageWhenWillIGetMoney.getVisibility() == View.VISIBLE) {
					pageWhenWillIGetMoney.setVisibility(View.GONE);
					imagWhenWillIGetMoney.setImageResource(R.drawable.plus_icon);
				} else {
					allPageGone();
					pageWhenWillIGetMoney.setVisibility(View.VISIBLE);
					imagWhenWillIGetMoney.setImageResource(R.drawable.minus_icon);
				}
			}
        });
		
		llytAmIApproved.setOnClickListener(new Button.OnClickListener() {    		
			@Override
			public void onClick(View v) {
				if (pageAmIApproved.getVisibility() == View.VISIBLE) {
					pageAmIApproved.setVisibility(View.GONE);
					imagAmIApproved.setImageResource(R.drawable.plus_icon);
				} else {
					allPageGone();
					pageAmIApproved.setVisibility(View.VISIBLE);
					imagAmIApproved.setImageResource(R.drawable.minus_icon);
				}
			}
        });
		
		llytWhatIsTheInterestRate.setOnClickListener(new Button.OnClickListener() {    		
			@Override
			public void onClick(View v) {
				if (pageWhatIsTheInterestRate.getVisibility() == View.VISIBLE) {
					pageWhatIsTheInterestRate.setVisibility(View.GONE);
					imagWhatIsTheInterestRate.setImageResource(R.drawable.plus_icon);
				} else {
					allPageGone();
					pageWhatIsTheInterestRate.setVisibility(View.VISIBLE);
					imagWhatIsTheInterestRate.setImageResource(R.drawable.minus_icon);
				}
			}
        });
		
		llytWhatIsTheLoanTerm.setOnClickListener(new Button.OnClickListener() {    		
			@Override
			public void onClick(View v) {
				if (pageWhatIsTheLoanTerm.getVisibility() == View.VISIBLE) {
					pageWhatIsTheLoanTerm.setVisibility(View.GONE);
					imagWhatIsTheLoanTerm.setImageResource(R.drawable.plus_icon);
				} else {
					allPageGone();
					pageWhatIsTheLoanTerm.setVisibility(View.VISIBLE);
					imagWhatIsTheLoanTerm.setImageResource(R.drawable.minus_icon);
				}
			}
        });
		
		llytHowDoIMakeChanges.setOnClickListener(new Button.OnClickListener() {    		
			@Override
			public void onClick(View v) {
				if (pageHowDoIMakeChanges.getVisibility() == View.VISIBLE) {
					pageHowDoIMakeChanges.setVisibility(View.GONE);
					imagHowDoIMakeChanges.setImageResource(R.drawable.plus_icon);
				} else {
					allPageGone();
					pageHowDoIMakeChanges.setVisibility(View.VISIBLE);
					imagHowDoIMakeChanges.setImageResource(R.drawable.minus_icon);
				}
			}
        });
		
		llytHaveAQuestion.setOnClickListener(new Button.OnClickListener() {    		
			@Override
			public void onClick(View v) {
				if (pageHaveAQuestion.getVisibility() == View.VISIBLE) {
					pageHaveAQuestion.setVisibility(View.GONE);
					imagHaveAQuestion.setImageResource(R.drawable.plus_icon);
				} else {
					allPageGone();
					pageHaveAQuestion.setVisibility(View.VISIBLE);
					imagHaveAQuestion.setImageResource(R.drawable.minus_icon);
				}
			}
        });
	}
	
	public void allPageGone() {
		imagWhatShouldIDoNow.setImageResource(R.drawable.plus_icon);
		imagWhenWillIGetMoney.setImageResource(R.drawable.plus_icon);
		imagAmIApproved.setImageResource(R.drawable.plus_icon);
		imagWhatIsTheInterestRate.setImageResource(R.drawable.plus_icon);
		imagWhatIsTheLoanTerm.setImageResource(R.drawable.plus_icon);
		imagHowDoIMakeChanges.setImageResource(R.drawable.plus_icon);
		imagHaveAQuestion.setImageResource(R.drawable.plus_icon);

		pageWhatShouldIDoNow.setVisibility(View.GONE);
		pageWhenWillIGetMoney.setVisibility(View.GONE);
		pageAmIApproved.setVisibility(View.GONE);
		pageWhatIsTheInterestRate.setVisibility(View.GONE);
		pageWhatIsTheLoanTerm.setVisibility(View.GONE);
		pageHowDoIMakeChanges.setVisibility(View.GONE);
		pageHaveAQuestion.setVisibility(View.GONE);
	}
}
